﻿Public Class FormCategoryRoom
    Dim DARoomCategory As New DSFloorManagemantTableAdapters.ROOM_CATEGORYTableAdapter

    
    Private Sub BtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSave.Click
        If ValidateTextField(TxtRoomCategory, "", ErrCategory) = False Then Exit Sub
        If lblSaveOption.Text = "0" Then
            If MessageBox.Show("Do you want save new room category?", "Room", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
                If DARoomCategory.NewRoomCategory(TxtRoomCategory.Text, TxtRoomCategoryDes.Text) = 1 Then
                    MessageBox.Show("Save successful.", "Room", MessageBoxButtons.OK, MessageBoxIcon.Information)
                    Me.DialogResult = Windows.Forms.DialogResult.OK
                Else
                    MessageBox.Show("Error save room category.", "Room", MessageBoxButtons.OK, MessageBoxIcon.Error)
                End If
            End If
        Else
            If MessageBox.Show("Do you want update room category?", "Room", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
                If DARoomCategory.UpdateRoomCategory(TxtRoomCategory.Text, TxtRoomCategoryDes.Text, lblSaveOption.Text) = 1 Then
                    MessageBox.Show("Update successful.", "Room", MessageBoxButtons.OK, MessageBoxIcon.Information)
                    Me.DialogResult = Windows.Forms.DialogResult.OK
                Else
                    MessageBox.Show("Error update room category.", "Room", MessageBoxButtons.OK, MessageBoxIcon.Error)
                End If
            End If
        End If
    End Sub

    Private Sub BtnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCancel.Click
        Me.Close()
    End Sub
End Class